//
//  OpinionViewController.m
//  gamebox_qpp
//
//  Created by 赵隆杰 on 2021/12/30.
//

#import "OpinionViewController.h"
#import "UserEditApi.h"

@interface OpinionViewController ()
@property (weak, nonatomic) IBOutlet UITextView *textView;
@property (weak, nonatomic) IBOutlet UIButton *submitButton;

@end

@implementation OpinionViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.centerTitle.text = @"意见反馈";
    
    self.submitButton.layer.cornerRadius = self.submitButton.height/2;
    self.submitButton.layer.masksToBounds = YES;
}

- (IBAction)submitClick:(id)sender {
    [self.view endEditing:YES];

    if (!self.textView.text.length) {
        [UIDevice.vg_rootWindow makeToast:@"请填写意见" duration:2 position:CSToastPositionCenter];
        return;
    }
    UserEditApi *api = [[UserEditApi alloc] initWithFeedback:self.textView.text username:@"" nickname:@"" password:@"" userpic:@""];
    [api startWithCompletionBlockWithSuccess:^(__kindof YTKBaseRequest * _Nonnull request) {
        if (api.success) {
            VHWeakSelf
            UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:@"您的宝贵意见已提交" preferredStyle:UIAlertControllerStyleAlert];
            UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
                [weakSelf.navigationController popViewControllerAnimated:YES];
            }];
            [alertController addAction:cancelAction];
            [self presentViewController:alertController animated:YES completion:nil];
        }
    } failure:^(__kindof YTKBaseRequest * _Nonnull request) {
    }];
    
}
@end
